package com.itheima.test;

public class test2case1 {
    public static void main(String[] args) {
        //调整字符串
        //A的最左边字符移动到最右边
        //经过若干次操作后A能编程B，那么返回true，否则返回false

        //1.定义两个字符串
        String strA = "abcde";
        String strB = "ABC";

        //2.调用方法进行比较
        boolean result = check(strA, strB);

        System.out.println(result);


    }

    //旋转字符串
    //方法1：substring截取拼接
    public static String rotate(String str){
        //截取
        char first = str.charAt(0);//获取最左侧的字符
        String end = str.substring(1);//从第一个字符开始一直到末尾
        return end+first;
    }

    //比较字符串是否相等
    public static boolean check(String strA, String strB){
        for (int i = 0; i < strA.length(); i++) {
            strA = rotate(strA);
            if(strA.equals(strB)) {
                return true;
            }
        }
        return false;
    }
}
